[stepper_x]
step_pin: PF0
dir_pin: PF1
enable_pin: !PD7
rotation_distance: 32
microsteps: 16
endstop_pin: ^!PE5
position_min: -8
position_endstop: -8
position_max: 270
homing_speed: 50.0
homing_retract_dist: 3.0
second_homing_speed: 5.0

[stepper_y]
step_pin: PF6
dir_pin: !PF7
enable_pin: !PF2
rotation_distance: 40
microsteps: 16
endstop_pin: ^!PD2
position_max: 215
position_min: -1
position_endstop: -1
homing_speed: 50.0
homing_retract_dist: 3.0
second_homing_speed: 5.0

[stepper_z]
step_pin: PL3
dir_pin: PL1
enable_pin: !PK0
rotation_distance: 4
microsteps: 16
endstop_pin: ^!PD3
position_endstop: 0.0
position_max: 195
homing_speed: 5.0
homing_retract_dist: 1.5
second_homing_speed: 0.8

[extruder]
step_pin: PA4
dir_pin: !PA6
enable_pin: !PA2
microsteps: 16
rotation_distance: 7.413
nozzle_diameter: 0.400
filament_diameter: 1.750
instantaneous_corner_velocity: 1.5
max_extrude_only_distance: 500
heater_pin: PB4
sensor_type: ATC Semitec 104GT-2
sensor_pin: PK5
smooth_time: 2
control: pid
pid_kp: 26.624
pid_ki: 1.571
pid_kd: 112.821
min_temp: 0
max_temp: 280
min_extrude_temp: 165
pressure_advance: 0.04

[heater_bed]
heater_pin: PH5
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PK6
control: pid
pid_kp: 71.189
pid_ki: 1.818
pid_kd: 696.767
min_temp: 0
max_temp: 125

[fan]
pin: PH6
kick_start_time: 1.0

[heater_fan heatbreak_fan]
pin: PL5
kick_start_time: 1.0
max_power: 1.0
heater_temp: 40.0
heater: extruder

[controller_fan system_fan]
pin: PH4
hardware_pwm: True
kick_start_time: 1.0
max_power: 1.0
idle_timeout: 120
idle_speed: 0.5
shutdown_speed: 1.0
heater: heater_bed,extruder
stepper: extruder,stepper_x,stepper_y,stepper_z

[output_pin light]
value: 1
pin: PL4

[mcu]
serial: /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0
restart_method: arduino

[printer]
kinematics: cartesian
max_velocity: 150
max_accel: 3000
max_accel_to_decel: 1500
max_z_velocity: 7
max_z_accel: 50
square_corner_velocity: 5

[bed_screws]
screw1: 5,11
screw2: 255,195
screw3: 5,195
screw4: 255,11

[filament_switch_sensor filament_sensor]
switch_pin: ^!PC4

[display_status]
[pause_resume]

[virtual_sdcard]
path: /var/lib/moonraker/gcodes

[gcode_arcs]
resolution: 0.4

[gcode_macro START_PRINT]
gcode:
    {% set BED_TEMP = params.BED_TEMP|default(60)|float %}
    {% set SPEED_TRAVEL = params.SPEED_TRAVEL|default(60)|float %}
    {% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(220)|float %}
    {% set STANDBY_TEMP = params.STANDBY_TEMP|default(150)|float %}
    G21 # millimeters units
    G90 # absolute positioning
    M82 # set extruder to absolute mode
    M107 # turn off fan
    M140 S{BED_TEMP} # start bed heating
    M104 S{STANDBY_TEMP} # start extruder heating
    SET_GCODE_OFFSET Z=0.0 # reset the G-Code Z offset
    G28 # home axes
    G0 Z1 F{SPEED_TRAVEL} # move the nozzle close to the bed
    G92 E0 # zero the extruded length
    M190 S{BED_TEMP} # wait for bed to reach temperature
    M109 S{EXTRUDER_TEMP} # set and wait for nozzle to reach temperature
    G0 F{SPEED_TRAVEL} # set movements speed

[gcode_macro END_PRINT]
gcode:
    M140 S0 # turn off bed heater
    M104 S0 # turn off extruder heater
    M107 # turn off fan
    G91 # relative positioning
    G1 E-2 F30 # retract a bit
    G1 X-3 Y-3 E-3 F3000 # move extruder away a bit and retract 
    G28 X # home X to min endstop
    G90 # absolute positioning
    G0 Y215 F3000 # move Y away
    G0 Z195 F3000 # move bed down
    M84 # disable steppers

[gcode_macro M205]
gcode:
  {% if 'X' in params %}
    SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={params.X}
  {% elif 'Y' in params %}
    SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={params.Y}
  {% endif %}
